home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 04 - 1988 / 04.03 Mar 88 / Basic source / WINDOW UPDATE.BAS next >
Encoding:
BASIC Source File  |  1988-01-07  |  3.6 KB  |  181 lines  |  [TEXT/ZBAS]

  1. ' WINDOW UPDATE DEMO
  2. ' ©1988 MacTutor®
  3. ' By Dave Kelly
  4.  
  5. WINDOW OFF
  6. COORDINATE WINDOW
  7. DEF MOUSE=-1
  8. DIM Wptr&(3)
  9.  
  10. APPLE MENU "About Updating…"
  11. MENU 1,0,1,"File"
  12. MENU 1,1,1,"Quit"
  13. EDIT MENU 2
  14. MENU 3,0,1,"Window"
  15. MENU 3,1,1,"Show Window 1"
  16. MENU 3,2,1,"Show Window 2"
  17. MENU 3,3,1,"Show Window 3"
  18. MENU 3,4,1,"Show All Windows"
  19.  
  20. 'Find out monitor size just in case we need it
  21. CALL GETWMGRPORT(WMgrPort&)
  22. PortTop=PEEK WORD(WMgrPort&+8)
  23. PortLeft=PEEK WORD(WMgrPort&+10)
  24. PortBottom=PEEK WORD(WMgrPort&+12)
  25. PortRight=PEEK WORD(WMgrPort&+14)
  26.  
  27. WINDOW#1,"Window 1",(PortLeft+4,PortTop+42)-(300,300),5
  28. Wptr&(1)=WINDOW(14)
  29. TEXT 3,12
  30. EDIT FIELD 1,"Read MacTutor!",(50,200)-(270,225),1
  31. GOSUB "Set Window 1 Update"
  32.  
  33. WINDOW#2,"Window 2",(PortLeft+24,PortTop+62)-(320,320),5
  34. Wptr&(2)=WINDOW(14)
  35. 'NOW... Create the picture for the first window
  36. PICTURE ON
  37. TEXT 2,24,1
  38. COLOR=4
  39. PRINT@(3,1)"MacTutor®"
  40. COLOR=7
  41. TEXT 3,12,0
  42. PRINT@(6,4)"The Best in the West!"
  43. PRINT@(5,6)"This is the second window"
  44. PICTURE OFF,Pic2&
  45. PICTURE, Pic2&:' Draw the picture
  46. WINDOW PICTURE #2,Pic2&
  47.  
  48. WINDOW#3,"Window 3",(PortLeft+44,PortTop+82)-(340,340),5
  49. Wptr&(3)=WINDOW(14)
  50. x1=0:x2=300:y1=0:y2=300
  51. ' bytes used = 6 + ((y2-y1)+1) * ((x2-x1+1)* bpp + 7) / 8)
  52. DIM Pic3%(58293) :' Enough space reserved for 32 bits-per-pixel (MAC II)
  53. 'NOW... Create the picture for the third window
  54. TEXT 2,24,1
  55. COLOR=4
  56. PRINT@(3,1)"MacTutor®"
  57. COLOR=7
  58. TEXT 3,12,0
  59. PRINT@(6,4)"The Best in the West!"
  60. PRINT@(5,6)"This is the third window"
  61. GET (x1,y1)-(x2,y2),Pic3%(1)
  62. PUT (0,0),Pic3%(1),0
  63.  
  64.  
  65. ON DIALOG GOSUB "DialogEvent"
  66. ON MENU GOSUB "MenuEvent"
  67. FLUSHEVENTS
  68. MENU ON:DIALOG ON
  69.  
  70. "Loop"
  71. GOTO "Loop"
  72. MENU OFF:DIALOG OFF
  73.  
  74. "DialogEvent"
  75. D=DIALOG(0)
  76. SELECT D
  77.     CASE 3
  78.         WINDOW DIALOG(3)
  79.     CASE 4
  80.         CALL HIDEWINDOW(Wptr&(DIALOG(4)))
  81.     CASE 5,6,7
  82.         IF DIALOG(5)=3 THEN GOSUB"Window3 Update" ELSE GOSUB "Set Window 1 Update"
  83. END SELECT
  84. RETURN
  85.  
  86. "MenuEvent"
  87. Menunumber=MENU(0)
  88. Menuitem=MENU(1)
  89. MENU
  90. SELECT Menunumber
  91.     CASE 255
  92.         GOSUB "AppleMenu"
  93.     CASE 1
  94.         GOSUB "FileMenu"
  95.     CASE 3
  96.         GOSUB "WindowMenu"
  97. END SELECT
  98. RETURN
  99.  
  100. "AppleMenu"
  101. WINDOW 4,"",(100,100)-(400,250),-2
  102. PICTURE ON
  103. TEXT 0,12,0,0
  104. PRINT @(2,2) "(ZBASIC) Window Update Demo V1.0"
  105. PRINT @(10,3)"by"
  106. PRINT @(8,4)"Dave Kelly"
  107. COLOR=6
  108. PRINT @(7,6)"©MacTutor, 1988"
  109. COLOR=7
  110. PRINT @(7,7)"ZBasic version 4.01"
  111. PICTURE OFF,Pic4&
  112. PICTURE ,Pic4&
  113. WINDOW PICTURE #4,Pic4&
  114. MOUSE ON
  115. DO
  116. mous=MOUSE(0)
  117. outsiderect=(MOUSE(1)<0 OR MOUSE(1)>300 OR MOUSE(2)<0 OR MOUSE(2)>150)
  118. IF MOUSE(1)=0 AND MOUSE(2)=0 THEN "Stop"
  119. UNTIL mous<>0 AND NOT (outsiderect)
  120. MOUSE OFF
  121. KILL PICTURE Pic4&:' Delete the picture from memory
  122. DIALOG ON
  123. WINDOW CLOSE 4
  124. DIALOG OFF
  125. RETURN
  126.  
  127. "Window3 Update"
  128. ActiveWindow=WINDOW(0)
  129. WINDOW OUTPUT 3
  130. PUT (0,0),Pic3%(1),0
  131. WINDOW OUTPUT ActiveWindow
  132. RETURN
  133.  
  134. "Set Window 1 Update"
  135. ActiveWindow=WINDOW(0)
  136. WINDOW OUTPUT 1
  137. 'NOW... Create the picture for the first window
  138.     KILL PICTURE Pic1&
  139.     PICTURE ON
  140.     TEXT 2,24,1
  141.     COLOR=4
  142.     PRINT@(3,1)"MacTutor®"
  143.     COLOR=7
  144.     TEXT 3,12,0,0
  145.     PRINT@(6,4)"The Best in the West!"
  146.     PRINT@(5,6)"This is the first window"
  147.     Editvariable$=EDIT$(1)
  148.     PRINT@(5,8)"The edit field = ";Editvariable$
  149.     PICTURE OFF,Pic1&
  150. PRINT@(5,8);SPC(100)
  151. PICTURE, Pic1&:' Draw the picture
  152. WINDOW OUTPUT ActiveWindow
  153. RETURN
  154.  
  155. "FileMenu"
  156. IF Menuitem=1 THEN "Stop"
  157. RETURN
  158.  
  159. "WindowMenu"
  160. SELECT Menuitem
  161.     CASE 1
  162.         CALL SHOWWINDOW(Wptr&(1)):WINDOW 1
  163.     CASE 2
  164.         CALL SHOWWINDOW(Wptr&(2)):WINDOW 2
  165.     CASE 3
  166.         CALL SHOWWINDOW(Wptr&(3)):WINDOW 3
  167.     CASE 4
  168.         FOR i=1 TO 3
  169.             CALL SHOWWINDOW(Wptr&(i))
  170.             WINDOW i
  171.         NEXT i
  172. END SELECT
  173. RETURN
  174.  
  175. "Stop"
  176. WINDOW PICTURE #1,0:'Don't update the first window anymore
  177. KILL PICTURE Pic1&:' Delete the picture from memory
  178. WINDOW PICTURE #2,0:'Don't update the second window anymore
  179. KILL PICTURE Pic2&:' Delete the picture from memory
  180. END
  181.